package com.alibaba.otter.node.etl.load.loader.mq.rabbit;

import com.google.common.collect.Sets;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.Set;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MqConstants {

    public static final String IGNORE_HEADER_SPAN = "span";

    public static final Set<String> IGNORE_HEADERS = Sets.newHashSet(IGNORE_HEADER_SPAN);

    /**
     * 默认的预取消息数量
     */
    public static final int DEFAULT_PREFETCH_SIZE = 200;

    /**
     * 允许预取的最大消息数量 {@link ListenerBuilder#prefetch(int)}
     */
    public static final int MAX_PREFETCH_SIZE = 2000;

    /**
     * 默认的消费线程数量
     */
    public static final int DEFAULT_CONSUME_THREAD_COUNT = 1;


    /**
     * 默认重连的间隔，单位毫秒
     */
    public static final int RECONNECT_INTERVAL_IN_MS = 1000;

    /**
     * 默认重发的间隔，单位毫秒
     */
    public static final int RESEND_INTERVAL_IN_MS = 1000;

    /**
     * 重新创建channel的间隔，单位毫秒
     */
    public static final int RECREATE_CHANNEL_INTERVAL_IN_MS = 1000;


    /**
     * 连接异常提示
     */
    public static final String CONNECTION_ERROR_TIP = "连接异常，消费消息失败。";

    /**
     * 消费线程名称前缀
     */
    public static final String CONSUMER_THREAD_NAME = "mq-consumer";

    /**
     * 消息的投递模式， 2 - 持久化
     */
    public static final int DEFAULT_DELIVERY_NODE = 2;


    /**
     * 未知异常
     */
    public static final int ERROR_CODE_UNEXPECTED = -1;

    /**
     * 连接异常
     */
    public static final int ERROR_CODE_CONNECTION = -2;

    /**
     * 配置异常
     */
    public static final int ERROR_CODE_CONFIG = -3;

    /**
     * 序列化异常
     */
    public static final int ERROR_CODE_SERIALIZE = -4;

    /**
     * 通用异常
     */
    public static final int ERROR_CODE_COMMON = -9;

    /**
     * ShutdownSignal ERROR CODE
     */
    public static final int SHUTDOWN_SIGNAL_NOT_FOUND = 404;

    public static final int DEFAULT_MIN_CHANNEL_SIZE = 1;
    public static final int DEFAULT_CORE_CHANNEL_SIZE = 5;
    public static final int DEFAULT_MAX_CHANNEL_SIZE = 100;

    /**
     * RescueAction的返回值
     */
    public static final int ACTION_FAIL = 0B0000_0000_0000;
    public static final int ACTION_SUCCESS = 0B0000_0000_0001;
    public static final int BREAK_CHAIN = 0B0000_0001_0000;
    public static final int SKIP_END = 0B0001_0000_0000;
}
